package Month11.Day11;

import java.util.*;

public class T1Test {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("请输入字符串");
        String s = in.next();
        String[] split = s.split("");
        Map<String, Integer> map = new HashMap<>();
        for (String str : split)
            map.put(str, map.getOrDefault(str, 0) + 1);
        List<Map.Entry<String, Integer>> list = new ArrayList<Map.Entry<String, Integer>>(map.entrySet());
        Collections.sort(list, new Comparator<Map.Entry<String, Integer>>() {
            @Override
            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
                return o2.getValue().compareTo(o1.getValue());
            }
        });
        for (Map.Entry<String, Integer> map1 : list)
            System.out.println(map1.getKey() + "," + map1.getValue());

    }


}




